<template>
  <div>
    <el-dialog :title="title" :visible.sync="form.dialogFormVisible">
      <el-form :model="form">
        <el-form-item
          :label="v.title"
          :label-width="formLabelWidth"
          v-for="(v, i) in ruleList"
          :key="i"
        >
          <el-input v-model="form['name']" v-if="v.field == 'name'"></el-input>
          <el-input v-model="form['code']" v-if="v.field == 'code'"></el-input>
          <el-input v-model="form['sort']" v-if="v.field == 'sort'"></el-input>

          <el-radio-group v-model="form['is_show']" v-if="v.field == 'is_show'">
            <el-radio :label="1">显示</el-radio>
            <el-radio :label="0">隐藏</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="form.dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: ["title", "form", "ruleList"],
  data() {
    return {
      formLabelWidth: "120px",
    };
  },

  methods: {
    submit() {
      this.$emit("finish", this.form);
    },
  },
};
</script>
<style lang="less" scoped></style>
